package com.mdb.open.trade.feign.fallback;
/*
 * Copyright (C), 2017-2019 澳发科技(MDB)
 * FileName: ProductClientFallBackFactory.java
 * Author:   符楚
 * Date:     2019-07-12 11:26
 * History:
 * <author>          <time>          <version>          <desc>
 * 符楚               2019-07-12          V1.00             新建
 * -----------------------------------------------------------
 * 作者姓名           修改时间           版本号            描述
 */

import com.mdb.bc.api.data.ResultEx;
import com.mdb.bc.api.enums.ResultCode;
import com.mdb.open.trade.feign.RiskClient;
import com.mdb.open.trade.feign.dto.StartRiskModelDto;
import com.mdb.open.trade.feign.vo.RiskModelRecordVo;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * <br>
 * <br>
 *
 * @author 符楚
 * @Date 2019-07-12 11:26
 */
@Slf4j
@Component
public class RiskClientFallbackFactory implements FallbackFactory<RiskClient> {

    @Override
    public RiskClient create(Throwable throwable) {
        log.error("调用风控中心服务[cnt-risk-service]发生异常", throwable);
        ResultEx result = ResultEx.makeResult(ResultCode.INVOKING_REMOTE_SERVICE, "调用风控中心服务发生异常");
        return new RiskClient() {
            @Override
            public ResultEx<RiskModelRecordVo> start(StartRiskModelDto dto) {
                result.setRetMsg("启动风控模型失败");
                return result;
            }
        };
    }
}
